package query

import (
	"context"
	"ddd-practice/domain"
)

type AllProductsHandler struct {
	productRepo domain.Repository
}

func NewAllProductsHandler(repository domain.Repository) AllProductsHandler {
	return AllProductsHandler{
		productRepo: repository,
	}
}

func (h AllProductsHandler) Handle(ctx context.Context) (*[]domain.Product, error) {
	list, _, err := h.productRepo.GetPage(ctx, 1, 10000)
	if err != nil {
		return nil, err
	}
	return list, nil
}
